import 'package:flutter/material.dart';
import 'package:flutter04/controller/list_controller.dart';
import 'package:flutter04/pages/form.dart';
import 'package:flutter04/pages/search.dart';
import 'package:get/get.dart';

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  ListController listController = Get.find<ListController>();

  @override
  Widget build(BuildContext context) {
    return ListView(
      padding: const EdgeInsets.fromLTRB(10, 10, 10, 50),
      children: [
        Obx(() => Text("当前计数：${listController.count.value}")),
        const SizedBox(
          height: 20,
        ),
        const Text("动画"),
        const Divider(),
        ElevatedButton(
          onPressed: () {
            Navigator.pushNamed(context, "/ae01");
          },
          child: const Text("隐式动画"),
        ),
        ElevatedButton(
          onPressed: () {
            Navigator.pushNamed(context, "/att");
          },
          child: const Text("显式动画"),
        ),
        ElevatedButton(
          onPressed: () {
            Navigator.pushNamed(context, "/ai");
          },
          child: const Text("动画图标"),
        ),
        ElevatedButton(
          onPressed: () {
            Navigator.pushNamed(context, "/gv");
          },
          child: const Text("GridView+Hero动画"),
        ),
        // ElevatedButton(
        //   onPressed: () {
        //     Navigator.pushNamed(context, "/hp", arguments: {});
        //   },
        //   child: const Text("Hero动画"),
        // ),
        const SizedBox(
          height: 20,
        ),
        const Divider(),
        const Text("基本路由跳转"),
        const Divider(),
        ElevatedButton(
          onPressed: () {
            Navigator.of(context).push(
              MaterialPageRoute(builder: (BuildContext context) {
                return const SearchPage();
              }),
            );
          },
          child: const Text("搜索"),
        ),
        const SizedBox(
          height: 20,
        ),
        ElevatedButton(
          onPressed: () {
            Navigator.of(context).push(
              MaterialPageRoute(builder: (BuildContext context) {
                return const FormPage();
              }),
            );
          },
          child: const Text("表单"),
        ),
        const SizedBox(
          height: 20,
        ),
        ElevatedButton(
          onPressed: () {
            // Navigator.of(context).push(
            //   MaterialPageRoute(builder: (BuildContext context) {
            //     return const NewsPage(
            //       arguments: {"title": "我是谁"},
            //     );
            //   }),
            // );
            Get.toNamed("/news", arguments: {"title": "我是谁"});
          },
          child: const Text("新闻"),
        ),
        const Divider(),
        const SizedBox(
          height: 20,
        ),
        const Text("命名路由跳转"),
        const Divider(),
        ElevatedButton(
          onPressed: () {
            Navigator.pushNamed(context, "/search");
          },
          child: const Text("搜索"),
        ),
        ElevatedButton(
          onPressed: () {
            Navigator.pushNamed(context, "/form");
          },
          child: const Text("表单"),
        ),
        ElevatedButton(
          onPressed: () {
            Navigator.pushNamed(context, "/news",
                arguments: {"title": "新闻呢", "aid": 20});
          },
          child: const Text("新闻"),
        ),
        ElevatedButton(
          onPressed: () {
            Get.toNamed("/shop", arguments: {"title": "购物呀", "aid": 20});
          },
          child: const Text("Shop"),
        ),
        const Divider(),
        const SizedBox(
          height: 20,
        ),
        const Text("命名路由跳转 - Dialog"),
        const Divider(),
        ElevatedButton(
          onPressed: () {
            Navigator.pushNamed(context, "/dialog");
          },
          child: const Text("Dialog演示"),
        ),
        const Divider(),
        const SizedBox(
          height: 20,
        ),
        const Text("命名路由跳转 - PageView"),
        const Divider(),
        ElevatedButton(
          onPressed: () {
            Navigator.pushNamed(context, "/pv");
          },
          child: const Text("PageView演示"),
        ),
        ElevatedButton(
          onPressed: () {
            Navigator.pushNamed(context, "/pvb");
          },
          child: const Text("PageViewBuilder演示"),
        ),
        ElevatedButton(
          onPressed: () {
            Navigator.pushNamed(context, "/pvbfp");
          },
          child: const Text("PageView无限加载演示"),
        ),
        ElevatedButton(
          onPressed: () {
            Navigator.pushNamed(context, "/pvs");
          },
          child: const Text("PageView轮播图演示"),
        ),
        ElevatedButton(
          onPressed: () {
            Navigator.pushNamed(context, "/pvk");
          },
          child: const Text("PageView KeepAlive 演示"),
        ),
        ElevatedButton(
          onPressed: () {
            Navigator.pushNamed(context, "/al");
          },
          child: const Text("AnimatedListPage 演示"),
        ),
        const Text("命名路由跳转 - PageWithoutKeyPage"),
        const Divider(),
        ElevatedButton(
          onPressed: () {
            Navigator.pushNamed(context, "/pnk");
          },
          child: const Text("PageWithoutKeyPage演示"),
        ),
      ],
    );
  }
}
